<?php

namespace app\apigovernment\controller;

use app\common\controller\Api;
use think\Config;
use think\Exception;

/**
 * 招聘会数据
 */
class InviteSetting extends Api
{
    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];

    protected $failException = true;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\apigovernment\model\InviteSetting();
        if (!Config::get('fastadmin.usercenter')) {
            $this->error(__('User center already closed'));
        }
    }

    /**
     * 数据
     * @return void
     */
    public function info(){
        try {
            $data = $this->model->find();
            $this->success('ok',$data);
        }catch (Exception $e){
            $this->error($e->getMessage());
        }
    }


    /**
     * 修改数据
     * @return void
     */
    public function save(){
        $input = input('post.');
        try {
            $id = $input['id'];
            unset($input['id']);
            $data = $this->model->where('id' , $id)->update($input);
            $this->success('ok',$data);
        }catch (Exception $e){
            $this->error($e->getMessage());
        }
    }
}